﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Devonline.Core;

namespace Devonline.Entity
{
    /// <summary>
    /// 字符串类型的默认基类
    /// </summary>
    [Table("key_value_pair"), DisplayName("键值对")]
    public class KeyValuePair : EntitySetWithKeyValuePair<string>
    {
    }

    /// <summary>
    /// 键值对存储数据的基类
    /// </summary>
    public abstract class EntitySetWithKeyValuePair<TKey> : EntitySetWithCreate<TKey>, IEntitySetWithKeyValuePair<TKey> where TKey : IConvertible
    {
        /// <summary>
        /// 序号
        /// </summary>
        [Column("index"), DisplayName("序号"), Excel]
        public virtual int Index { get; set; }
        /// <summary>
        /// 键
        /// </summary>
        [Column("key"), DisplayName("键"), Required, MaxLength(128), Excel]
        public virtual string Key { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        [Column("value"), DisplayName("值"), Required, MaxLength(256), Excel]
        public virtual string Value { get; set; }
    }
}
